package com.dmatek.uwb.local.xml.middleware;

import java.net.SocketException;

import com.dmatek.uwb.packet.bean.ENodeInfor;
import com.dmatek.uwb.packet.bean.TagInfor;
import com.dmatek.uwb.packet.ianalysis.callback.IReportCallBack;
import com.dmatek.uwb.util.tool.NetWorkUtil;
import com.dmatek.uwb.util.tool.StringUtil;
/***
 * 定位配置中间件抽象类
 * @author zhangfu
 * @data 2019年6月22日 下午2:52:32
 * @Description
 */
public abstract class BaseLocalConfigMiddle implements IConfigMiddle{
	private String xmlPath;
	private IReportCallBack<TagInfor> tagReportCallBack;
	private IReportCallBack<ENodeInfor> eNodeReportCallBack;
	public BaseLocalConfigMiddle(String xmlPath, 
			IReportCallBack<TagInfor> tagReportCallBack,
			IReportCallBack<ENodeInfor> eNodeReportCallBack) {
		this.xmlPath = xmlPath;
		this.tagReportCallBack = tagReportCallBack;
		this.eNodeReportCallBack = eNodeReportCallBack;
	}
	/***
	 * 检验端口是否有效
	 * @param port
	 * @return
	 */
	protected final boolean checkPort(int port) {
		if(port <= 0 || port > 65535) {
			return false;
		} 
		return true;
	}
	/***
	 * 校验ip是否有效
	 * @param ip
	 * @return
	 * @throws SocketException
	 */
	protected final boolean checkIp(String ip) throws SocketException {
		if(StringUtil.isEmpty(ip)) {
			return false;
		} 
		if(!NetWorkUtil.isLocalIp(ip)) {
			return false;
		}
		return true;
	}
	public String getXmlPath() {
		return xmlPath;
	}
	public void setXmlPath(String xmlPath) {
		this.xmlPath = xmlPath;
	}
	public IReportCallBack<TagInfor> getTagReportCallBack() {
		return tagReportCallBack;
	}
	public void setTagReportCallBack(IReportCallBack<TagInfor> tagReportCallBack) {
		this.tagReportCallBack = tagReportCallBack;
	}
	public IReportCallBack<ENodeInfor> geteNodeReportCallBack() {
		return eNodeReportCallBack;
	}
	public void seteNodeReportCallBack(
			IReportCallBack<ENodeInfor> eNodeReportCallBack) {
		this.eNodeReportCallBack = eNodeReportCallBack;
	}
}
